<?
/**
 * Google RSS News Plugin for Gnuboard4
 *
 * Copyright (c) 2008 Choi Jae-Young <www.miwit.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가

$plugin_path = "$g4[path]/plugin/google-news2";

?>

<style type="text/css">
#google-news { width:645px; overflow:hidden; background-color:#e1e1e1; border-top:2px solid #72ACE7; }
#google-news td { background-color:#fff; }
#google-news a { color:#2F3743; }
#google-news .subject { background-color:#fcfcfc; width:130px; height:25px; font-weight:bold; overflow:hidden; }
#google-news .subject .margin {  margin:5px 0 0 15px; }
#google-news #list { float:left; margin:0; padding:0; list-style:none; width:130px; height:160px;  }
#google-news #list .margin {  padding:5px 0 0 15px; }
#google-news #list li { height:17px; line-height:17px; }
#google-news #list .gn_item { color:#6B6D70; font-size:11px; font-family:dotum; }
#google-news #list .gn_item:hover { color:#000; text-decoration:underline; }
#google-news #list .gn_sel { color:#6079A8; text-decoration:underline; font-weight:bold; font-size:11px; }

#google-news #news ul { float:left; margin:0; padding:0; list-style:none; margin:5px 5px 5px 10px; overflow:hidden; }
#google-news #news li { width:280px; height:21px; line-height:20px; overflow:hidden; float:left; }
#google-news #news li { margin:0; padding:0 0 0 7px; background:url(<?=$plugin_path?>/img/dot.gif) no-repeat 0 7px; }
#google-news #news li a { font-size:12px; }
#google-news #news li a:hover { color:#438A01; text-decoration:underline; }
#google-news #news li a:visited {  }
#google-news #news li a:active { color:#438A01;  }
#google-news #news .image { float:left; margin:10px 0 0 10px; width:80px; height:80px; padding:0; }
#google-news #news .image img { width:70px; height:80px; }

#google-news .today { font-size:11px; }
#ajax-loading { display:none; position:absolute; margin:5px 5px 0 385px; }
</style>

<table border="0" cellpadding="0" cellspacing="1" id="google-news">
<tr>
    <td class="subject" valign="top">
        <div class="margin">구글뉴스</div>
    </td>
    <td style="background-color:#F8F8F8; padding-left:10px;">
        <div class="today">
            <img src="<?=$plugin_path?>/img/icon_clock.gif" align="absmiddle">
            <span id="mw-today"></span><span id="mw-time"></span>
        </div>
    </td>
<tr>
    <td width="130">
        <ul id="list">
            <div class="margin">
            <li><a href="javascript:mw_google_news('')" id="gn-" class="gn_item">주요뉴스</a></li>
            <li><a href="javascript:mw_google_news('p')" id="gn-p" class="gn_item">정치</a></li>
            <li><a href="javascript:mw_google_news('y')" id="gn-y" class="gn_item">사회</a></li>
            <li><a href="javascript:mw_google_news('l')" id="gn-l" class="gn_item">문화/생활</a></li>
            <li><a href="javascript:mw_google_news('w')" id="gn-w" class="gn_item">세계</a></li>
            <li><a href="javascript:mw_google_news('t')" id="gn-t" class="gn_item">정보과학</a></li>
            <li><a href="javascript:mw_google_news('s')" id="gn-s" class="gn_item">스포츠</a></li>
            <li><a href="javascript:mw_google_news('e')" id="gn-e" class="gn_item">연예</a></li>
            </div>
        </ul>
    </td>
    <td valign="top" >
        <div id="ajax-loading"><img src="<?=$plugin_path?>/img/loading.gif"></div>
        <div id="news"></div>
    </td>
</tr>
</table>

<script type="text/javascript" src="<?=$g4[path]?>/js/jquery.js"></script>
<script type="text/javascript">
gns = new Array();
gns[0] = "";
gns[1] = "p";
gns[2] = "y";
gns[3] = "l";
gns[4] = "w";
gns[5] = "t";
gns[6] = "s";
gns[7] = "e";
gns_idx = -1;
gns_time = "";
function mw_google_news(topic) {
    $("#news").load("<?=$plugin_path?>/get_news.php?topic="+topic);
    $(".gn_sel").each(function () {
        $(this).removeClass().addClass("gn_item");
    });
    $("#gn-"+topic).removeClass().addClass("gn_sel");
    for (i=0; i<gns.length; i++) {
        if (gns[i] == topic) {
            gns_idx = i;
        }
    }
}
function mw_google_news_change() {
    if (++gns_idx >= gns.length)
        gns_idx = 0;
    mw_google_news(gns[gns_idx]);
    gns_time = setTimeout("mw_google_news_change()", 9000);
}
$(document).ready(function() {
    $("#ajax-loading").ajaxStart(function() { 
	//$("#news").hide();
	$(this).show(); 
    }).ajaxStop(function() { 
	$(this).hide(); 
	$("#news").show();
    });
});
mw_google_news_change();

$("#google-news").hover(function () {
    clearTimeout(gns_time);
}, function () {
    gns_time = setTimeout("mw_google_news_change()", 9000);
});
    

mw_timer_init = <?=time()*1000?>;
function mw_timer() {
    mw_timer_init += 1000;
    var date = new Date(mw_timer_init);
    var month = date.getMonth() + 1;
    var day = date.getDate();
    var time = date.toLocaleTimeString();
    var wstr = "일월화수목금토";
    var week = wstr.substr(date.getDay(),1);
    if (month < 10) month = "0" + month;
    if (day < 10) day = "0" + day;
    //var str = month + "월 " + day + "일 " + "(" + week + ") ";
    var str = month + "." + day + " (" + week + ") ";
    document.getElementById("mw-today").innerHTML =  str;
    document.getElementById("mw-time").innerHTML = time;
    setTimeout("mw_timer()", 1000);
}
mw_timer();

</script>


